Skip to content

Stacked pull requests reach main after their base merges - #964

Merged
coderhelm[bot] merged 3 commits into
mainfrom
fix/stacked-merge-reaches-main
Dec 4, 2026
Merged

coderhelm[bot] merged 3 commits into
mainfrom
fix/stacked-merge-reaches-main

Conversation

@nambok

@nambok nambok commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A pull request stacked on another one could be merged into a branch nothing reads any more. When the first pull request merged and its branch stayed, GitHub left the stacked pull request on that branch, and the merge gate merged it there. The stacked pull request then showed as merged, but its change never reached the default branch.

Wider than the ticket: services/worker/src/passes/dead_base.rs: the defect is in how every stacked pull request's base is handled (on merge, at the gate and on the sweep), not in a lookup for a few named records, so the fix lives on those three paths.

Changes

  • When a pull request merges, a new stack_merged worker message moves the open pull requests based on its branch to its base. This always happens for CoderHelm's own pull requests, and for a person's when the repository's new retarget_stacked setting is on. The base is then merged into each moved pull request with GitHub's merge, which makes a signed commit; a conflict goes to the merge gate's own conflict path. Each one is reviewed again on its new base. CoderHelm's merged branch is deleted once nothing is based on it.
  • The merge gate never merges into a base that is the branch of an already merged pull request and is no longer read, unless that base is the default branch or the configured release branch. It moves the pull request first and waits for the review there. Where the merged pull request was a person's and retarget_stacked is off, it holds the pull request for a person to move instead of moving it.
  • A branch is still read, so never treated as merged, while an open pull request comes from it, while it is protected, or once it was the head of more than one merged pull request (a long-lived develop released into main). A merge from such a branch moves nothing based on it, and merges into it are never lost.
  • The pull request watch sweep moves open pull requests still based on a merged branch. For a change CoderHelm merged into one in the last 30 days, it opens one "Land #N on main" pull request that picks the change onto the branch it belonged on. Nothing is opened when that branch already holds the change. Each landing is claimed once, and a sweep opens at most three per repository. When picking the change or opening the pull request fails, the claim is given back, a landing branch left without a pull request is deleted, and the next sweep tries again; one failure does not stop the rest of the sweep.
  • The stack section of a stacked pull request now says what CoderHelm does when its base merges.
  • New incident case xn_stacked_merge_reaches_main, with its page.

Verification

  • Invented replays in the incident case:
    • A squash merge moves the stacked pull request, which then merges into main.
    • The gate refuses a base that already merged.
    • The gate holds a person's merged base with the setting off, and moves it once the setting is on.
    • A protected develop, a develop an open pull request comes from, and a develop released twice all stay live: the gate merges into them, the sweep moves and lands nothing, and a release from them moves nothing based on them.
    • The sweep moves the stacked pull request.
    • A lost merge gets one landing pull request.
    • A landing whose pull request fails to open, or whose pick fails, gives its claim back, leaves no branch, lets the other landings in the sweep go on, and lands on the next sweep.
    • A change already on main gets none.
    • Also covered: the repository setting for people's merges, the 30 day window, only CoderHelm's merges, and the per sweep cap.
  • cargo fmt --all --check, rustfmt --check on the incident files, clippy with -D warnings, and cargo test -p common -p worker -p gateway all pass.
  • brand_spelling.py and domain_examples.py pass.

When a pull request merges, the open pull requests based on its branch move
to its base, the base is merged into each, and each is reviewed there.
CoderHelm's merged branch is deleted once nothing is based on it. The merge
gate never merges into a base that is the branch of an already merged pull
request: it moves the pull request first and waits for the review. The pull
request watch sweep moves what is still based on such a branch, and opens
one "Land #N on main" pull request for a change CoderHelm merged into one in
the last 30 days, unless main already holds it.
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 4, 2026
coderhelm[bot]

This comment was marked as outdated.

coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 4, 2026 03:48

Superseded by CoderHelm's latest review

coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 4, 2026 04:49

Superseded by CoderHelm's latest review

A branch whose pull request merged is still read while an open pull
request comes from it, while it is protected, or once it was the head of
more than one merged pull request (a develop released again and again).
The merge gate, the merge handler and the watch sweep treat such a branch
as live: nothing based on it is moved and no merge into it is lost.

The merge gate follows the same rule as the sweep for a person's merged
pull request: with retarget_stacked off it neither merges into the dead
base nor moves the pull request, and holds it for a person to move.

A landing's claim goes back when picking the change or opening its pull
request fails, a landing branch left without a pull request is deleted,
and one failure no longer stops the rest of the repository's sweep.
coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 4, 2026 05:45

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

💚 Post-merge health check passed: the deploy of f250c0d completed and stayed green for the full 15-minute watch window (no new failures vs. the pre-merge baseline).
Auto-merge

  • ✅ CoderHelm approved
  • ✅ CI green
    The rest is in the pull request description.

coderhelm[bot]

This comment was marked as outdated.

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes 8749c0f (merged)

@coderhelm
coderhelm Bot merged commit f250c0d into main Dec 4, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant